﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ElingOA6_Admin_DSJCJ.Common;
using System.Data;
using ElingOA6_Admin_DSJCJ.Models;
using System.IO;

namespace ElingOA6_Admin_DSJCJ.Areas.Admin.Controllers
{
    /// <summary>
    /// 上传下载目录管理
    /// </summary>
    /// <returns></returns>
    [OutputCache(Duration = 0, VaryByParam = "none")]
    public class EnterpriseFTPController : Controller
    {
        BLL.FTP_New FTP_NewBLL = new BLL.FTP_New();

        [AuthorityActionFilter("m_EnterpriseFTP", Order = 1)]
        [LogPageActionFilter("上传下载目录管理", Order = 2)]
        public ActionResult Index(string focusNodeName = "")
        {
            ViewData["focusNodeName"] = focusNodeName;
            List<Model.FTP_New> FTP_NewList = FTP_NewBLL.GetListByEntityNo(GlobalConstant.ENTITYNO);
            ViewData["isHaveTreeData"] = FTP_NewList.Count == 0 ? false : true;
            return View();
        }



        /// <summary>
        /// 左边栏目列表树
        /// </summary>
        /// <param name="focusNodeName">焦点名</param>
        /// <param name="type">类型</param>
        /// <returns>视图</returns>
        public ActionResult EnterpriseFTPTree(string focusNodeName = "")
        {
            TreeModelList treeModelList = new TreeModelList();

            List<Model.FTP_New> FTP_NewList = FTP_NewBLL.GetListByEntityNo(GlobalConstant.ENTITYNO);
           
            if (FTP_NewList.Count > 0)
            {
                TreeItemModel NoArchiveRootUpload = new TreeItemModel(null)
                {
                    Id = Url.Action("EnterpriseFTP_NewEdit", "EnterpriseFTP", new { FId = 0, actionOP = BaseStruct.ActionOperationStruct.ADD_NEXT,Type=1 }),
                    Name = "上传"
                };
                //ViewData["SelectNodeName"] = "上传目录";
                // ViewData["focusNodeName"] = "上传目录";
                //  ViewData["SelectNodeName"] = Url.Action("EnterpriseFTP_NewEdit", "EnterpriseFTP", new { FId = 0, actionOP = BaseStruct.ActionOperationStruct.ADD_NEXT });
                treeModelList.Add(NoArchiveRootUpload);
                List<Model.FTP_New> FTP_NewFirstList = (from m in FTP_NewList
                                                        where m.FParentID == null & m.FIsArchive == "N" & m.FIsUpload == "Y"
                                                        select m).ToList();

                foreach (Model.FTP_New FTP_NewModel in FTP_NewFirstList)
                {
                    List<Model.FTP_New> tmpFTP_NewList = (from m in FTP_NewList
                                                          where m.FParentID == FTP_NewModel.FID & m.FIsArchive == "N"
                                                          select m).ToList();

                    TreeItemModel treeParentItemModel = new TreeItemModel(NoArchiveRootUpload)
                    {
                        Id = Url.Action("EnterpriseFTP_NewEdit", "EnterpriseFTP", new { FId = FTP_NewModel.FID, actionOP = BaseStruct.ActionOperationStruct.EDIT }),
                        Name = FTP_NewModel.FName
                    };
                    treeParentItemModel.Id = treeParentItemModel.Id.Replace("&", "|");
                    if (tmpFTP_NewList.Count > 0)
                    {
                        GetChildFTP_NewList(tmpFTP_NewList, treeParentItemModel, FTP_NewList);
                    }
                    // treeModelList.Add(treeParentItemModel);
                }
          
                 TreeItemModel NoArchiveRootDownload = new TreeItemModel(null)
            {
                Id = Url.Action("EnterpriseFTP_NewEdit", "EnterpriseFTP", new { FId = 0, actionOP = BaseStruct.ActionOperationStruct.ADD_NEXT ,Type =2}),
                Name = "下载"
            };
            //ViewData["SelectNodeName"] = "上传目录";
           // ViewData["focusNodeName"] = "上传目录";
          //  ViewData["SelectNodeName"] = Url.Action("EnterpriseFTP_NewEdit", "EnterpriseFTP", new { FId = 0, actionOP = BaseStruct.ActionOperationStruct.ADD_NEXT });
            treeModelList.Add(NoArchiveRootDownload);
           
                List<Model.FTP_New> FTP_NewFirstListDownload = (from m in FTP_NewList
                                                        where m.FParentID == null & m.FIsArchive == "N"&m.FIsDownload=="Y"
                                                        select m).ToList();

                foreach (Model.FTP_New FTP_NewModel in FTP_NewFirstListDownload)
                {
                    List<Model.FTP_New> tmpFTP_NewList = (from m in FTP_NewList
                                                          where m.FParentID == FTP_NewModel.FID & m.FIsArchive == "N"
                                                          select m).ToList();

                    TreeItemModel treeParentItemModel = new TreeItemModel(NoArchiveRootDownload)
                    {
                        Id = Url.Action("EnterpriseFTP_NewEdit", "EnterpriseFTP", new { FId = FTP_NewModel.FID, actionOP = BaseStruct.ActionOperationStruct.EDIT }),
                        Name = FTP_NewModel.FName
                    };
                    treeParentItemModel.Id = treeParentItemModel.Id.Replace("&", "|");
                    if (tmpFTP_NewList.Count > 0)
                    {
                        GetChildFTP_NewList(tmpFTP_NewList, treeParentItemModel, FTP_NewList);
                    }
                   // treeModelList.Add(treeParentItemModel);
                }
         
                TreeItemModel treeParentItemModelach = new TreeItemModel(null)
                {
                    Id = "",
                    Name = "归档目录"
                };
                treeModelList.Add(treeParentItemModelach);

                TreeItemModel ArchiveRootUpload = new TreeItemModel(treeParentItemModelach)
                {
                    Id = Url.Action("EnterpriseFTP_NewEdit", "EnterpriseFTP", new { FId = 0, actionOP = BaseStruct.ActionOperationStruct.ADD_NEXT,Type = 1 }),
                    Name = "上传"
                };
                List<Model.FTP_New> FTP_NewFirstListach = (from m in FTP_NewList
                                                           where m.FParentID == null & m.FIsArchive == "Y" & m.FIsUpload == "Y"
                                                           select m).ToList();
                foreach (Model.FTP_New FTP_NewModel in FTP_NewFirstListach)
                {
                    List<Model.FTP_New> tmpFTP_NewList = (from m in FTP_NewList
                                                          where m.FParentID == FTP_NewModel.FID & m.FIsArchive == "Y"
                                                          select m).ToList();

                    TreeItemModel treeParentItemModel = new TreeItemModel(ArchiveRootUpload)
                    {
                        Id = Url.Action("EnterpriseFTP_NewEdit", "EnterpriseFTP", new { FId = FTP_NewModel.FID, actionOP = BaseStruct.ActionOperationStruct.EDIT }),
                        Name = FTP_NewModel.FName
                    };
                    treeParentItemModel.Id = treeParentItemModel.Id.Replace("&", "|");
                    if (tmpFTP_NewList.Count > 0)
                    {
                        GetChildFTP_NewListach(tmpFTP_NewList, treeParentItemModel, FTP_NewList);
                    }
                 //   treeModelList.Add(treeParentItemModel);
                }
                TreeItemModel ArchiveRootDownload = new TreeItemModel(treeParentItemModelach)
                {
                    Id = Url.Action("EnterpriseFTP_NewEdit", "EnterpriseFTP", new { FId = 0, actionOP = BaseStruct.ActionOperationStruct.ADD_NEXT,Type =2 }),
                    Name = "下载"
                };

                List<Model.FTP_New> FTP_NewFirstListDownloadach = (from m in FTP_NewList
                                                           where m.FParentID == null & m.FIsArchive == "Y" & m.FIsDownload == "Y"
                                                           select m).ToList();
                foreach (Model.FTP_New FTP_NewModel in FTP_NewFirstListDownloadach)
                {
                    List<Model.FTP_New> tmpFTP_NewList = (from m in FTP_NewList
                                                          where m.FParentID == FTP_NewModel.FID & m.FIsArchive == "Y"
                                                          select m).ToList();

                    TreeItemModel treeParentItemModel = new TreeItemModel(ArchiveRootDownload)
                    {
                        Id = Url.Action("EnterpriseFTP_NewEdit", "EnterpriseFTP", new { FId = FTP_NewModel.FID, actionOP = BaseStruct.ActionOperationStruct.EDIT }),
                        Name = FTP_NewModel.FName
                    };
                    treeParentItemModel.Id = treeParentItemModel.Id.Replace("&", "|");
                    if (tmpFTP_NewList.Count > 0)
                    {
                        GetChildFTP_NewListach(tmpFTP_NewList, treeParentItemModel, FTP_NewList);
                    }
                    //   treeModelList.Add(treeParentItemModel);
                }
            }
            ViewData["focusNodeName"] = focusNodeName;
            return PartialView(treeModelList);
        }


        public void GetChildFTP_NewList(List<Model.FTP_New> FTP_NewChildList, TreeItemModel treeParentItemModel, List<Model.FTP_New> FTP_NewList)
        {
            foreach (Model.FTP_New FTP_NewModel in FTP_NewChildList)
            {
                List<Model.FTP_New> tmpFTP_NewList = (from m in FTP_NewList
                                                      where m.FParentID == FTP_NewModel.FID & m.FIsArchive == "N"
                                                      select m).ToList();

                TreeItemModel treeChildItemModel = new TreeItemModel(treeParentItemModel)
                {
                    Id = Url.Action("EnterpriseFTP_NewEdit", "EnterpriseFTP", new { FId = FTP_NewModel.FID, actionOP = BaseStruct.ActionOperationStruct.EDIT }),
                    Name = FTP_NewModel.FName
                };
                treeChildItemModel.Id = treeChildItemModel.Id.Replace("&", "|");
                if (tmpFTP_NewList.Count > 0)
                {
                    GetChildFTP_NewList(tmpFTP_NewList, treeChildItemModel, FTP_NewList);
                }
            }
        }


        public void GetChildFTP_NewListach(List<Model.FTP_New> FTP_NewChildList, TreeItemModel treeParentItemModel, List<Model.FTP_New> FTP_NewList)
        {
            foreach (Model.FTP_New FTP_NewModel in FTP_NewChildList)
            {
                List<Model.FTP_New> tmpFTP_NewList = (from m in FTP_NewList
                                                      where m.FParentID == FTP_NewModel.FID & m.FIsArchive == "Y"
                                                      select m).ToList();

                TreeItemModel treeChildItemModel = new TreeItemModel(treeParentItemModel)
                {
                    Id = Url.Action("EnterpriseFTP_NewEdit", "EnterpriseFTP", new { FId = FTP_NewModel.FID, actionOP = BaseStruct.ActionOperationStruct.EDIT }),
                    Name = FTP_NewModel.FName
                };
                treeChildItemModel.Id = treeChildItemModel.Id.Replace("&", "|");
                if (tmpFTP_NewList.Count > 0)
                {
                    GetChildFTP_NewListach(tmpFTP_NewList, treeChildItemModel, FTP_NewList);
                }
            }
        }
        public string SaveArchive(string FID)
        {
            try
            {
                FTP_NewBLL.ChangeArchiveY(decimal.Parse(FID));
                return "SUCCESS";
            }
            catch (System.Exception ex)
            {
                return "错误:原因" + ex.Message.ToString();
            }

        }
        public string DelArchive(string FID)
        {
            try
            {
                FTP_NewBLL.ChangeArchiveN(decimal.Parse(FID));
                return "SUCCESS";
            }
            catch (System.Exception ex)
            {
                return "错误:原因" + ex.Message.ToString();
            }

        }

        public ActionResult EnterpriseFTP_NewEdit(decimal FId = 0, string actionOP = BaseStruct.ActionOperationStruct.ADD_NEXT,int Type=1)
        {
            return EnterpriseFTP_NewEdit(FId, actionOP, "",Type);
        }

        private ActionResult EnterpriseFTP_NewEdit(decimal FId, string actionOP, string jsAlert, int Type = 1)
        {
            string entityNo = GlobalConstant.ENTITYNO;
            ViewData["isChild"] = FTP_NewBLL.GetChildCount(FId, entityNo);

            Model.FTP_New FTP_NewModel = new Model.FTP_New();


            Model.FTP_New oldFTP_NewModel = FTP_NewBLL.GetModel(FId);

            switch (actionOP)
            {
                case BaseStruct.ActionOperationStruct.ADD_SAME:
                case BaseStruct.ActionOperationStruct.ADD_NEXT:
                    {
                        FTP_NewModel = new Model.FTP_New();
                        if (actionOP == BaseStruct.ActionOperationStruct.ADD_SAME)
                        {
                            FTP_NewModel.FParentID = oldFTP_NewModel != null ? oldFTP_NewModel.FParentID : null;
                        }
                        else
                        {
                            if (oldFTP_NewModel != null)
                            {
                                FTP_NewModel.FParentID = oldFTP_NewModel.FID;
                            }
                            else
                            {
                                FTP_NewModel.FParentID = null;
                            }
                        }
                        //1上传，2下载
                        //获取上级栏目,无上级栏目可以修改、有上级栏目部可以
                        if (FTP_NewModel.FParentID == null)
                        {
                            ViewData["canChangeStatus"] = true;
                            if (actionOP == BaseStruct.ActionOperationStruct.ADD_SAME)
                            {

                                if (oldFTP_NewModel != null)
                                {
                                    if (oldFTP_NewModel.FIsUpload == "Y" && oldFTP_NewModel.FIsDownload == "N")
                                    {
                                         FTP_NewModel.ftpStatus = "1";
                                    } 
                                    else
                                    {
                                         FTP_NewModel.ftpStatus = "2";
                                    }
                                }
                                else
                                {

                                    FTP_NewModel.ftpStatus = "1";
                                }
                               
                            }
                            else
                            {
                                if (Type == 1)
                                {

                                    FTP_NewModel.ftpStatus = "1";
                                }
                                if (Type == 2)
                                {
                                    FTP_NewModel.ftpStatus = "2";
                                }
                            }
                        }
                        else
                        {
                            //暂时都能修改
                            //ViewData["canChangeStatus"] = false;
                            ViewData["canChangeStatus"] = true;
                            //如果有上级栏目，就按照上级的栏目属性来
                            Model.FTP_New parentFTP_NewModel = FTP_NewBLL.GetModel(FTP_NewModel.FParentID.Value);
                            if (parentFTP_NewModel.FIsUpload == "Y" && parentFTP_NewModel.FIsDownload == "N")
                            {
                                FTP_NewModel.ftpStatus = "1";
                            }
                            else if (parentFTP_NewModel.FIsUpload == "N" && parentFTP_NewModel.FIsDownload == "Y")
                            {
                                FTP_NewModel.ftpStatus = "2";
                            }
                        }
                        if (oldFTP_NewModel != null)
                        {

                            FTP_NewModel.FIsArchive = oldFTP_NewModel.FIsArchive;
                        }
                        else
                        {
                            FTP_NewModel.FIsArchive = "N";

                        }
                        break;
                    }
                case BaseStruct.ActionOperationStruct.EDIT:
                    {
                        FTP_NewModel = oldFTP_NewModel;
                        if (FTP_NewModel.FParentID == null)
                        {
                            ViewData["canChangeStatus"] = true;
                        }
                        else
                        {
                            //暂时都能修改
                            //ViewData["canChangeStatus"] = false;
                            ViewData["canChangeStatus"] = true;
                        }
                        if (FTP_NewModel.FIsUpload == "Y" && FTP_NewModel.FIsDownload == "N")
                        {
                            FTP_NewModel.ftpStatus = "1";
                        }
                        else if (FTP_NewModel.FIsUpload == "N" && FTP_NewModel.FIsDownload == "Y")
                        {
                            FTP_NewModel.ftpStatus = "2";
                        }

                        break;
                    }

            }

            //获取当前目录的上级目录
            if (FTP_NewModel.FParentID != null)
            {
                DataTable dtPreFTP_New = FTP_NewBLL.GetListPre(FTP_NewModel.FParentID.Value);
                string strPreFTP_New = "";
                foreach (DataRow row in dtPreFTP_New.Rows)
                {
                    strPreFTP_New += row["FName"].ToString() + "/";
                }
                FTP_NewModel.strPreFTP = strPreFTP_New;
                ViewData["arch"] = false;
                ViewData["isarched"] = FTP_NewModel.FIsArchive == "Y" ? true : false;
            }
            else
            {
                ViewData["isarched"] = FTP_NewModel.FIsArchive == "Y" ? true : false;
                ViewData["arch"] = true;
            }
          
            ViewData["jsAlert"] = jsAlert;
            //隐藏字段
            ViewData["hdMethod"] = actionOP.ToString();

            return View("EnterpriseFTP_NewEdit", FTP_NewModel);
        }
         public string ExistFTPFname(string FID,string FName)
        {

            if (string.IsNullOrEmpty(FID))
            {
                if (FTP_NewBLL.ExistSameNameWithNewNameWhenNull( FName))
                {
                    return "yes";
                }
                else
                {

                    return "no";
                }
            }

            else
            {
                if (FTP_NewBLL.ExistSameNameWithNewName(decimal.Parse(FID), FName))
                {
                    return "yes";
                }
                else
                {

                    return "no";
                }
            }
        }
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="docClsModel">信息类别实体类</param>
        [HttpPost]
        public ActionResult Save(Model.FTP_New FTP_NewModel)
        {
            string scxzFilePath = System.Configuration.ConfigurationManager.AppSettings["scxzFilePath"];
            string errorMessage = "";
            ActionResult actionResult = null;
            string entityNo = GlobalConstant.ENTITYNO;
            Model.FTP_New newFTP_NewModel = new Model.FTP_New();
            decimal FId = 0;
            if (Fetch.Post("hdFParentID") != null && Fetch.Post("hdFParentID") != "")
            {
                newFTP_NewModel.FParentID = decimal.Parse(Fetch.Post("hdFParentID"));
            }
            else
            {
                newFTP_NewModel.FParentID = null;
            }

            if (bool.Parse(Fetch.Post("harch").ToString()))
            {
                newFTP_NewModel.FIsArchive = "Y";

            }
            else
            {
                newFTP_NewModel.FIsArchive = "N";
            }
            newFTP_NewModel.FName = FTP_NewModel.FName;
            newFTP_NewModel.FType = "D";
            newFTP_NewModel.FLogID = OperateSession.get(Common.GlobalConstant.PARAM_LOGINID);
            newFTP_NewModel.FEntityNo = Common.GlobalConstant.ENTITYNO;
            newFTP_NewModel.ftpStatus = Fetch.Post("hdftpStatus");
            if (newFTP_NewModel.ftpStatus == "1")
            {
                newFTP_NewModel.FIsUpload = "Y";
                newFTP_NewModel.FIsDownload = "N";
            }
            else if (newFTP_NewModel.ftpStatus == "2")
            {
                newFTP_NewModel.FIsUpload = "N";
                newFTP_NewModel.FIsDownload = "Y";
            }
            bool isSuccess = true;
            switch (Fetch.Post("hdMethod"))
            {
                case BaseStruct.ActionOperationStruct.EDIT:
                    {
                        var mdl = FTP_NewBLL.GetModelList((newFTP_NewModel.FParentID == null ? "FParentID is null" : "FParentID='" + newFTP_NewModel.FParentID.ToString() + "'") + " and FName='" + newFTP_NewModel.FName + "' and FType='D'");

                        if (mdl.Count > 0)
                        {
                            errorMessage = "错误：已存在相同文件夹";
                            if (actionResult == null)
                            {
                                actionResult = EnterpriseFTP_NewEdit(decimal.Parse(Fetch.Post("hdFID")), Fetch.Post("hdMethod"), errorMessage);
                            }
                            break;
                        }
                        else
                        {
                            if (isSuccess)
                            {
                                try
                                {
                                    string dirPath = scxzFilePath;
                                    if (newFTP_NewModel.FParentID != null)
                                    {
                                        dirPath += GetPathByPid(newFTP_NewModel.FParentID.Value);
                                    }
                                    Model.FTP_New OldFtp_NewModel = FTP_NewBLL.GetModel(decimal.Parse(Fetch.Post("hdFID")));
                                    string oldPath = dirPath + OldFtp_NewModel.FName;
                                    string newPath = dirPath + newFTP_NewModel.FName;
                                    myDisk myDisk = new myDisk();
                                    myDisk.MoveDir(oldPath, newPath);
                                    isSuccess = true;
                                }
                                catch
                                {
                                    isSuccess = false;
                                }
                            }

                            //再修改数据
                            try
                            {
                                newFTP_NewModel.FID = decimal.Parse(Fetch.Post("hdFID"));

                                FId = newFTP_NewModel.FID;
                                FTP_NewBLL.UpdateFTP_New(newFTP_NewModel);

                                ViewData["RedirectURL"] = Url.Action("EnterpriseFTP_NewEdit", "EnterpriseFTP", new
                                {
                                    FId = newFTP_NewModel.FID,
                                    actionOP = BaseStruct.ActionOperationStruct.EDIT,
                                    jsAlert = ""
                                });

                                ViewData["methodFromType"] = Fetch.Post("hdMethod");
                                ViewData["nodeText"] = newFTP_NewModel.FName;
                                actionResult = View("SuccessMessageByTree");
                            }
                            catch (Exception ex)
                            {
                                errorMessage = "错误：" + ex.ToString();
                            }
                            if (actionResult == null)
                            {
                                actionResult = EnterpriseFTP_NewEdit(FTP_NewModel.FID, Fetch.Post("hdMethod"), errorMessage);
                            }
                            break;
                        }
                    }
                case BaseStruct.ActionOperationStruct.ADD_SAME:
                case BaseStruct.ActionOperationStruct.ADD_NEXT:
                    {
                        //增加
                        //先增加文件夹
                        if (isSuccess)
                        {
                            try
                            {
                                string dirPath = scxzFilePath;
                                if (newFTP_NewModel.FParentID != null)
                                {
                                    dirPath += GetPathByPid(newFTP_NewModel.FParentID.Value);
                                }
                                dirPath += newFTP_NewModel.FName;
                                myDisk myDisk = new myDisk();
                                myDisk.CreateDir(dirPath);
                                isSuccess = true;
                            }
                            catch
                            {
                                isSuccess = false;
                            }
                        }

                        //再增加数据
                        if (isSuccess)
                        {
                            try
                            {
                                var mdl = FTP_NewBLL.GetModelList((newFTP_NewModel.FParentID == null ? "FParentID is null" : "FParentID='" + newFTP_NewModel.FParentID.ToString() + "'") + " and FName='" + newFTP_NewModel.FName + "' and FType='D'");

                                if (mdl.Count > 0)
                                {
                                    errorMessage = "错误：已存在相同文件夹";
                                }
                                else
                                {
                                    FId = FTP_NewBLL.AddFTP_New(newFTP_NewModel);
                                    FTP_NewModel = FTP_NewBLL.GetModel(FId);

                                    ViewData["methodFromType"] = Fetch.Post("hdMethod");
                                    ViewData["focusKey"] = Url.Action("EnterpriseFTP_NewEdit", "EnterpriseFTP", new { FId = FTP_NewModel.FID, actionOP = BaseStruct.ActionOperationStruct.EDIT });
                                    ViewData["focusKey"] = ViewData["focusKey"].ToString().Replace("&", "|");
                                    string a = ViewData["focusKey"].ToString();
                                    actionResult = View("SuccessMessageByTree");
                                }
                            }
                            catch (Exception ex)
                            {
                                errorMessage = "错误：" + ex.ToString();
                            }
                        }
                        if (actionResult == null)
                        {
                            actionResult = EnterpriseFTP_NewEdit(FTP_NewModel.FID, Fetch.Post("hdMethod"), errorMessage);
                        }
                        break;
                    }

            }
            return actionResult;
        }
        private string GetPathByPid(decimal pId)
        {
            DataTable dtPreFTP = FTP_NewBLL.GetListPre(pId);
            string strPreFTP = "";
            foreach (DataRow row in dtPreFTP.Rows)
            {
                strPreFTP += row["FName"].ToString() + "\\";
            }
            return strPreFTP;
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="FID"></param>
        /// <returns></returns>
        public string DeleteFTP(decimal FID)
        {
            string scxzFilePath = System.Configuration.ConfigurationManager.AppSettings["scxzFilePath"];
            string errorMessage = "";
            try
            {
                //判断是否存在文件
                if (FTP_NewBLL.ExistChildFTP_New(FID))
                {
                    errorMessage = "EXISTCHILDFTP_New";
                }
                else if (FTP_NewBLL.ExistFile(FID))
                {
                    errorMessage = "EXISTFILE";
                }
                else
                {
                //   Model.FTP_New modelftp = FTP_NewBLL.GetModel(FID);
                 //   decimal pid =decimal.Parse(modelftp.FParentID.ToString());
                    string path =(scxzFilePath+ GetPathByPid(FID)).Trim('\\');
                    if (Directory.Exists(path))
                    {
                        Directory.Delete(path);
                    }
                    FTP_NewBLL.deleteFTP_New(FID);
                    errorMessage = "SUCCESS";
                }
            }
            catch (Exception ex)
            {
                errorMessage = "ERROR|程序错误，错误：" + ex.ToString();
            }
            return errorMessage;
        }


    }
}
